/**
 * @(#) KLineStockIndicatorModel.java
 */

package org.vsg.stock.core.indicator;

import java.util.Iterator;
import java.util.List;
import java.util.Vector;

import org.vsg.stock.core.KLineStock;

/**
 * @deprecated
 * 
 * @author Bill Vison
 *
 * @param <T>
 */
public class KLineStockIndicatorModel<T extends KLineStock> implements IndicatorModel {
	
	

	private List<Number> dataValues = new Vector<Number>();
	
	private List<T> klineStockList;
	
	public KLineStockIndicatorModel(List<T> klineStockList , KLineStockIndicatorModel.KLinePosition posi) {

		this. klineStockList = klineStockList;
		initInst( klineStockList , posi);
		
	}

	public KLineStockIndicatorModel(List<T> klineStockList ) {
		this(klineStockList , KLinePosition.CLOSE);
	}
	
	
	private void initInst(List<T> klineStockListInLife , KLineStockIndicatorModel.KLinePosition posi) {
		
		for (T inst : klineStockListInLife) {
			
			switch (posi) {
				
				case OPEN: 
					dataValues.add( inst.getOpen() );
					break;
					
				case HIGH:
					dataValues.add( inst.getHigh() );
					break;
					
				case LOW:
					dataValues.add( inst.getLow() );
					break;
					
				case VOL:
					dataValues.add( inst.getVol() );
					break;
					
				case TRANSACTION_VALUE:
					dataValues.add( inst.getTransactionValue() );
					break;
					
				default :
					dataValues.add( inst.getClose() );
					break;
					
			}
			
		}
		
		
	}

	
	
	@Override
	public T getIndexRef(int index) {
		// TODO Auto-generated method stub
		return this.klineStockList.get( index );
	}

	/**
	 * @return 
	 */
	@Override
	public List<Number> getDataValues(){
		return dataValues;
	}
	
	/**
	 * @return 
	 */
	@Override
	public int size(){
		return dataValues.size();
	}
	
	/**
	 * @return 
	 */
	@Override
	public Iterator iterator(){
		return dataValues.iterator();
	}
	
	public enum KLinePosition {
		OPEN, HIGH, LOW,CLOSE,VOL,TRANSACTION_VALUE
	}
	
	
}
